package logic.nodes;

import logic.nodes.collision.visibility.SightType;

import com.jme.bounding.BoundingSphere;
import com.jme.scene.Controller;

public class TeamNodeSphereController extends Controller {
	
	private static final long serialVersionUID = 1L;
	
	public static final float NORMAL_VIEW_DIST = 300;
	public static final float MOTHERSHIP_VIEW_DIST = 400;
	public static final float SPAWN_STATION_VIEW_DIST = 350;
	
	private TeamNode node;
	
	public TeamNodeSphereController(TeamNode node) {
		this.node = node;
	}
	
	@Override
	public void update(float time) {
		if(node.getBound() != null) {
			addSphere(SightType.Normal, NORMAL_VIEW_DIST);
			addSphere(SightType.MotherShip, MOTHERSHIP_VIEW_DIST);
			addSphere(SightType.SpawnStation, SPAWN_STATION_VIEW_DIST);
			node.removeController(this);
		}
	}
	
	private void addSphere(SightType type, float radius) {
		BoundingSphere sphere = new BoundingSphere();
		sphere.setRadius(radius);
		sphere.setCenter(node.getLocalTranslation());
		node.setSightSphere(sphere, type);
	}
}